package com.sofwin.configer;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.util.Properties;

/**
 * @packageName: com.sofwin.configer
 * @user: andyliu
 * @date: 2021/12/13 15:11
 * @email 115176513@qq.com
 * @description: TODO
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.sofwin")
public class RootConfiger {

    @Bean
    public Config getConfig(){
        Properties pros = new Properties();
        pros.setProperty("kaptcha.border","yes");
        pros.setProperty("kaptcha.border.color","105,179,90");
        pros.setProperty("kaptcha.textproducer.font.color","blue");
        pros.setProperty("kaptcha.image.width","125");
        pros.setProperty("kaptcha.image.height","45");
        pros.setProperty("kaptcha.textproducer.font.size","30");
        pros.setProperty("kaptcha.textproducer.char.length","4");
        Config config = new Config(pros);
        return config;
    }

    @Bean
    public DefaultKaptcha getKaptcha(){
        DefaultKaptcha kaptcha = new DefaultKaptcha();
        kaptcha.setConfig(this.getConfig());
        return kaptcha;
    }
}
